package com.gksc.video.config;

import lombok.extern.slf4j.Slf4j;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.FFmpegFrameRecorder;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

/**
 * @className: StartHandler
 * @description: 服务启动处理类
 * @author: Liao.yx
 * @email: 1229053515@qq.com
 * @create: 2020年09月24日 18时59分
 * @copyRight: 2020 liaoyongxiang All rights reserved.
 **/
@Slf4j
@Component
public class StartHandler implements ApplicationListener<ApplicationReadyEvent>, Ordered {

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        try {
            log.info("init ffmpeg grabber and recorder");
            FFmpegFrameGrabber.tryLoad();
            FFmpegFrameRecorder.tryLoad();
        } catch (Exception e) {
            log.error("系统异常，异常原因是", e);
            e.printStackTrace();
        }
        log.info("-------------------------Start All Done-----------------------------");
    }


    @Override
    public int getOrder() {
        return 0;
    }
}
